﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace ProtoTableauAffretes.Converters
{
    public class NoteToColorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool isForegroundColor = parameter != null && parameter.ToString() == "foreground";
            double note = (double)value;
            if (note < 70.0)
                return isForegroundColor ? new SolidColorBrush(Colors.Black) : new SolidColorBrush(Colors.Red);
            else if (note < 85.0)
                return isForegroundColor ? new SolidColorBrush(Colors.Black) : new SolidColorBrush(Colors.Orange);
            else if (note < 100.0)
                return isForegroundColor ? new SolidColorBrush(Colors.Black) : new SolidColorBrush(Colors.Yellow);
            else
                return isForegroundColor ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Green);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return Binding.DoNothing;
        }
    }
}
